

package com.hexinfo.dmpro.sparing.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.common.annotation.AnonymousAccess;
import com.hexinfo.dmpro.common.model.MessageCenter;
import com.hexinfo.dmpro.common.service.MessageCenterService;
import com.hexinfo.dmpro.sparing.service.HdfsHeatBackupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.sparing.model.DataSyncConf;
import com.hexinfo.dmpro.sparing.service.DataSyncConfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 数据同步配置表
 *
 * @author yemw
 * @date 2023-08-30 09:56:26
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/datasyncconf" )
@Api(value = "datasyncconf", tags = "数据同步配置表管理")
public class DataSyncConfController {

    private final  DataSyncConfService dataSyncConfService;

    private final  HdfsHeatBackupService hdfsHeatBackupService;


    @GetMapping("/timeoutEnd" )
    @AnonymousAccess
    public void getDataSyncConfPage() {
        hdfsHeatBackupService.timeoutEnd();
    }

    /**
     * 分页查询
     * @param page 分页对象
     * @param dataSyncConf 数据同步配置表
     * WrapperEnhancer.like(dataSyncConf); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @AnonymousAccess
    public ResponseEntity<Object> getDataSyncConfPage(Page page, DataSyncConf dataSyncConf) {
        return ResponseEntity.ok(dataSyncConfService.queryList(page,dataSyncConf));
    }


    /**
     * 通过id查询数据同步配置表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public ResponseEntity<Object> getById(@PathVariable("id" ) String id) {
        return ResponseEntity.ok(dataSyncConfService.getById(id));
    }

    /**
     * 新增数据同步配置表
     * @param dataSyncConf 数据同步配置表
     * @return R
     */
    @ApiOperation(value = "新增数据同步配置表", notes = "新增数据同步配置表")
    @PostMapping
    @AnonymousAccess
    public ResponseEntity<Object> save(@RequestBody DataSyncConf dataSyncConf) {
        return ResponseEntity.ok(dataSyncConfService.save(dataSyncConf));
    }

    /**
     * 修改数据同步配置表
     * @param dataSyncConf 数据同步配置表
     * @return R
     */
    @ApiOperation(value = "修改数据同步配置表", notes = "修改数据同步配置表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody DataSyncConf dataSyncConf) {
        return ResponseEntity.ok(dataSyncConfService.updateById(dataSyncConf));
    }

    /**
     * 通过id删除数据同步配置表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除数据同步配置表", notes = "通过id删除数据同步配置表")
    @DeleteMapping("/{id}" )
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(dataSyncConfService.removeById(id));
    }

}
